#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<unordered_map>
#include<algorithm>
using namespace std;

vector<vector<string>> groupAnagrams(vector<string>& strs) {
    unordered_map<string, vector<string>> hashMap;
    for (auto& e : strs) {
        string key = e;
        sort(key.begin(), key.end());
        hashMap[key].push_back(e);
    }

    vector<vector<string>> ret;
    for (auto& e : hashMap) {
        //sort(e.second.begin(), e.second.end());
        ret.push_back(e.second);
    }
    return ret;
}

int numberOf2sInRange(int n) {
    int ret = 0;
    for (long long i = 1; i <= n; i *= 10) {
        int cur = n / i % 10;
        if (cur > 2) {
            ret += n / i / 10 * i + i;
        }
        else if (cur < 2) {
            ret += n / i / 10 * i;
        }
        else {
            ret += n / i / 10 * i + n % i + 1;
        }
    }
    return ret;
}